using System;
using System.Windows.Forms;
using ctsu.BaseForms;

namespace ctsu.Admin.BusLogic
{
	public class FormBaseControllerImpl : IFormBaseController
	{
		private FormBase _form;
		private IBLFormBase _bl;

		public FormBaseControllerImpl(FormBase form, IBLFormBase bl)
		{
			this._form = form;
			this._bl = bl;
		}

		public IBLFormBase BusinessLogic
		{
			get { return this._bl; }
		}

		#region IFormClose implementation
		public void Accept(object sender, System.EventArgs e)
		{
			this._bl.Save();
		}

		public void Exit(object sender, System.EventArgs e)
		{
			this._bl.Exit();
		}

		public void Cancel(object sender, System.EventArgs e)
		{
			this._bl.Cancel();
		}

		public void Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			e.Cancel = _bl.Closing();
			Console.WriteLine("Form_Closing e.cancel=" + e.Cancel.ToString());
		}
		#endregion IFormClose implementation
		#region IFormController implementation
		public FormBase Form
		{
			get { return _form; }
			set { _form = value; }
		}

		public void Search(object sender, System.EventArgs e)
		{
			this._bl.Search(sender);
		}

		public void New(object sender, System.EventArgs e)
		{
			Control ctl = (Control)sender;
			Console.WriteLine("Sender name:" + ctl.Name);
			this._bl.New();
		}

		public void Edit(object sender, System.EventArgs e)
		{
			Control ctl = (Control)sender;
			Console.WriteLine("Sender name:" + ctl.Name);
			this._bl.Edit();
		}

		public void Remove(object sender, System.EventArgs e)
		{
			Control ctl = (Control)sender;
			Console.WriteLine("Sender name:" + ctl.Name);
			this._bl.Remove();
		}

		public void ShowGrid(object sender, System.EventArgs e)
		{
			this._bl.ShowGrid();
		}

		public void CarryNewClicked(object sender, System.EventArgs e)
		{
			this._bl.CarryNewClicked(sender);
		}

		public void GenericClick(object sender, System.EventArgs e)
		{
			this._bl.GenericClick((Control)sender);
		}

		public void GenericDoubleClick(object sender, System.EventArgs e)
		{
			this._bl.GenericDoubleClick((Control)sender);
		}

		#endregion IFormController implementation


	}
}
